package com.tcps.wechat_push.service.impl;

import com.tcps.wechat_push.entity.Jobbean;
import com.tcps.wechat_push.entity.PlanBusshiftBusEntity;
import com.tcps.wechat_push.job.PushJob;
import com.tcps.wechat_push.mapper.PlanBusshiftBusMapper;
import com.tcps.wechat_push.service.IWeChatService;
import com.tcps.wechat_push.util.QuartzManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author greenlee
 * @version v1.0
 * @create 创建时间: 2018-07-17 17:17
 * Copyright 2018  by 三水林科技有限公司
 **/
@Service("weChatService")
public class WeChatService implements IWeChatService {
    @Autowired
    private PlanBusshiftBusMapper planBusshiftBusMapper;
    @Override
    public boolean pushPlanBusshiftBus() {
        Jobbean job = new Jobbean();
        job.setId(0);
        job.setJobName("jobname");
        job.setJobGroup("job_group");
       return QuartzManager.addJob("name", PushJob.class, "*/5 * * * * ?", job);
    }

    @Override
    public List queryPlan() {
        List<PlanBusshiftBusEntity> planBusshiftBusEntities =null;
        Map<String,String> params = new HashMap<String,String>();
//        List<PlanBusshiftBusEntity> driverPlans = PlanBusshiftBusDao.selectPlanBusShiftDriver(params);
        List<PlanBusshiftBusEntity> driverPlans = planBusshiftBusMapper.selectPlanBusShiftDriver(params);
        int size = driverPlans.size();
        planBusshiftBusEntities=driverPlans;
//        JSONObject entityJson = null;
        if (driverPlans != null && driverPlans.size() != 0) {
//            for (int i = 0; i < driverPlans.size(); i++) {
//                entityJson = new JSONObject();
//                entityJson.put("planFromTime", driverPlans.get(i).getFromTime().toString());
//                entityJson.put("lineNo", driverPlans.get(i).getLineName());
//                entityJson.put("busNo", driverPlans.get(i).getBusCode());
//                entityJson.put("fromBusstop", driverPlans.get(i).getFromBusstop());
//                entityJson.put("driverName", driverPlans.get(i).getDriverName());
//                entityJson.put("upDown", driverPlans.get(i).getUpDown());
//                entityJson.put("updateFromTime", driverPlans.get(i).getUpdateFromTime());
//                resultObject.add(entityJson);
//            }

        } else {
//            logger.debug("getPlanBusShiftDriver():工作计划查询：查无结果");
//            return "CodeError";
        }
        return planBusshiftBusEntities;
    }


}
